	var modul_id = new Array(8);
	
	modul_id[0] = 206;
	modul_id[1] = 204;
	modul_id[2] = 203;
	modul_id[3] = 205;
	modul_id[4] = 208;
	modul_id[5] = 209;
	modul_id[6] = 202;
	modul_id[7] = 207;
	modul_id[8] = 210;
	modul_id[9] = 231;	
	
	defmenu_key = 0;
	defmenu_id = modul_id[defmenu_key];
	
	defmenu_key_e = 9;
	defmenu_id_e = modul_id[defmenu_key_e];	
	
	var do_cek;
	var bl_cek;
	var id_modul;
	var tabsnya;
	
	function show_bl_data() {
//		alert('data_diambil');
		if (xmlHttp.readyState == 4) 
		{
		  	if (xmlHttp.status == 200)
		  	{
				var response = xmlHttp.responseText.split("|");
//				alert(response[0]);
//				alert (response[0] + ", " + response[8]);
				if (response[8] == '') bl_cek = false;
				else
				{
					bl_cek = true;
					if (response[0] == '') do_cek = false;
					else do_cek = true;
				}
			 	if (bl_cek)
			 	{
				 	if (! do_cek || do_cek )
				 	{						
//					 	alert (frm_module.location);
					 	window.top.frm_module.location='cashier.php?p=' + id_modul + '&no_bl=' + window.top.document.form1.no_bl.value;
//					 	alert(frm_module.location);
				 		for (i=0; i < 9;i++)
				 		{
			//	 	 		alert (form1["but[" + i + "]"].value);
				 	 		window.top.document.form1["but[" + i + "]"].className = 'form_5';	 	 			 				 		
				 	 	} 
		//				 	alert ('a');				 	 	
		//	 	 		alert (tabs.value);
			 	 		tabsnya.className = 'form_3';
		//	 			alert (tabs.Style);
			 	 	} else 
			 	 	{
			 	 		alert ('DO No for this BL has not been released yet');
			 	 		window.top.frm_module.location='cashier.php';
			 	 		return false;
			 	 	}
				 } else
				 {
				 	 alert ('BL No is not exist');
					 window.top.frm_module.location='cashier.php';				 	 			
				 	 return false;
				 }
			} else if (xmlHttp.status == 404)
			{
				alert("Request URL does not exist");
				window.top.frm_module.location='cashier.php';
				return false;
			} else 
			{
				alert("Error: status code is " + xmlHttp.status);
				window.top.frm_module.location='cashier.php';				
				return false;
			}
		}
	}	
	
	 function cek_key (event, field,tcash)
	 {
	 	var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
//	 		alert (keyCode);	 	
//		alert (field.name + "," + keyCode);
//		alert (field);
	 	if (keyCode == 13 && field != null && field.name == 'no_bl')
	 	{	 		
	 		i = 0;
	 		
			if (tcash == 1) cek_bl(window.top.document.getElementById('but[' + defmenu_key_e + ']'), defmenu_id_e);
			else cek_bl(window.top.document.getElementById('but[' + defmenu_key + ']'), defmenu_id);
				
	 		return false;
	 	} else
		{			
//			alert ('bbb');	
			if (event.ctrlKey && event.shiftKey && (keyCode == 10 || keyCode == 74) ) cek_bl(window.top.document.getElementById('but[0]'), modul_id[0]);
			else if (event.ctrlKey && event.shiftKey && (keyCode == 4 || keyCode == 68) ) cek_bl(window.top.document.getElementById('but[1]'), modul_id[1]);		
			else if (event.ctrlKey && event.shiftKey && (keyCode == 5 || keyCode == 69) ) cek_bl(window.top.document.getElementById('but[2]'), modul_id[2]);				
			else if (event.ctrlKey && event.shiftKey && (keyCode == 6 || keyCode == 70) ) cek_bl(window.top.document.getElementById('but[3]'), modul_id[3]);						
			else if (event.ctrlKey && event.shiftKey && (keyCode == 12 || keyCode == 76) ) cek_bl(window.top.document.getElementById('but[4]'), modul_id[4]);								
			else if (event.ctrlKey && event.shiftKey && (keyCode == 16 || keyCode == 80) ) cek_bl(window.top.document.getElementById('but[5]'), modul_id[5]);										
			else if (event.ctrlKey && event.shiftKey && (keyCode == 1 || keyCode == 65) ) cek_bl(window.top.document.getElementById('but[6]'), modul_id[6]);										
			else if (event.ctrlKey && event.shiftKey && (keyCode == 9 || keyCode == 73) ) cek_bl(window.top.document.getElementById('but[7]'), modul_id[7]);										
			else if (event.ctrlKey && event.shiftKey && (keyCode == 15 || keyCode == 79) ) cek_bl(window.top.document.getElementById('but[8]'), modul_id[8]);																		
		 	
//		 	return false;
		 }	 		 		 		 		 	
	 } 
	 			
	 function cek_bl(tabs,id)
	 {
//		 alert('bl_dicek');
		 do_cek = bl_cek = false;	 
		 id_modul = id;	
		 tabsnya = tabs; 
		 var bl = window.top.document.form1.no_bl.value;
//		 alert(bl);
		 var url = "response.php?p=" + id_modul + "&func=bl_data&bl=" + escape(bl);
//		 alert ('aaa');
	 	 if (bl != '')
	 	 {		 		 
//			 alert(bl);
//			 alert(url);
			 xmlHttp.open("GET", url, true);			 
//			 alert(xmlHttp.status);
			 xmlHttp.onreadystatechange = show_bl_data;
			 xmlHttp.send(null);	
		 } else 
		 {
		   alert ('Please input No. BL');
			return false;	 	
		 }
//	 	 alert (do_cek);
	 }	 	 
	
	function cek_confirm(str)
	{
		if (str == undefined) str = 'Save this receipt?';		
		if (confirm(str) ) return true;
		else return false;
	}
	
	function go_focus (field, i)
	{
			if (field.form.elements[i].type != 'hidden' && field.form.elements[i].readOnly == false) 
			{
				field.form.elements[i].focus();
				field.form.elements[i].select();
			} else go_focus (field, (i+1) );
	}
	
	// tipe utk menentukan fieldnya apa. kalo tipe = 0 maka field biasa, kalo tipe = 1 maka field cuma bisa diinput Y/T
	
	function handleEnter (field, event, tipe) {		
		
		var keyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode;
	//	var keyCode = evt == null ? event.keyCode : evt.which;  		
	//	alert (event.keyCode + "," + event.which + "," + event.charCode);
//			alert (event.charCode);
//		alert(keyCode);
//		alert(event.ctrlKey + ", " + event.shiftKey + ", " + keyCode);
//		alert (window.top.document.getElementById('no_bl').value);
//		alert (window.top.document.getElementById('but[0]').value);
//aaaaaaaa
		if (keyCode == 13 || keyCode == 9 ) {
			not_error = true;
			if (tipe == 2 && field.value != '')
			{				
				not_error = cek_tanggal(field);
			}						
			if (not_error)
			{
				var i;
				for (i = 0; i < field.form.elements.length; i++)
					if (field == field.form.elements[i])
						break;
				i = (i + 1) % field.form.elements.length;
	//				alert (field.form.elements[i].readOnly);
				go_focus(field, i);
			}			
			return false;
		} else 
		{
//			alert(keyCode);
			if (tipe == 1) // untuk hanya bisa input Ya dan tidak
			{				
//				alert (keyCode);	
				if (keyCode == 116 || keyCode == 84) field.value = 'T';
				if (keyCode == 121 || keyCode == 89) field.value = 'Y';
				return false;
			} else if (tipe == 2) // untuk hanya bisa input tanggal
			{
//				alert(keyCode);
				error = false;
				if (keyCode < 48 || keyCode > 57) 
				{					
					if (keyCode == 8 || keyCode == 9 || keyCode == 37 || keyCode == 39 || keyCode == 45 || keyCode == 47) return true;
					else return false;
				}		
			} else if (tipe == 3) // untuk hanya bisa input numerik
			{
//					alert (keyCode);
//					alert (keyCode);
				if (keyCode < 48 || keyCode > 57) 
				{					
					if (keyCode == 8 || keyCode == 9 || keyCode == 37 || keyCode == 39) return true;
					else return false;
				} else 
				{
					return true;					
				}
			}
			return true;
		}
	}      
	
	var highlightcolor="#FFFFDF";
	var highlightfcolor = "#666666";
	
	var ns6=document.getElementById&&!document.all
	var previous=''
	var eventobj
	
	//Regular expression to highlight only form elements
	var intended=/INPUT|TEXTAREA|SELECT|OPTION/
	
	//Function to check whether element clicked is form element
	function checkel(which)
	{
		if (which.style&&intended.test(which.tagName))
		{
			if (ns6&&eventobj.nodeType==3) eventobj=eventobj.parentNode.parentNode
			return true
		} else return false
	}
	
	//Function to highlight form element
	function highlight(e)
	{
		eventobj=ns6? e.target : event.srcElement
		if (previous!='')
		{
			if (checkel(previous)) previous.style.backgroundColor=''
	
			previous.style.color='#000000';
			previous=eventobj
			if (checkel(eventobj)) eventobj.style.backgroundColor=highlightcolor
			eventobj.style.color=highlightfcolor
		} else{
			if (checkel(eventobj))
			eventobj.style.backgroundColor=highlightcolor
			eventobj.style.color=highlightfcolor
			previous=eventobj
		}
	}
	
	function print_data(p, nokwi, flag)
	{
//		var par = '&principal=' + form_search.principal.value + '&vessel=' + form_search.vessel.value;
		window.open('popup_pdf.php?p=' + p + '&act=PDF&id=' + nokwi + '&flag=' + flag,'winpdf','width=800,height=600,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no');
//		winpdf.focus();
	}		
	
	/**
	 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
	 */
	// Declaring valid date character, minimum year and maximum year
	var dtCh= "-";
	var minYear=1900;
	var maxYear=2100;
	
	function isInteger(s){
		var i;
	    for (i = 0; i < s.length; i++){   
	        // Check that current character is number.
	        var c = s.charAt(i);
	        if (((c < "0") || (c > "9"))) return false;
	    }
	    // All characters are numbers.
	    return true;
	}
	
	function stripCharsInBag(s, bag){
		var i;
	    var returnString = "";
	    // Search through string's characters one by one.
	    // If character is not in bag, append to returnString.
	    for (i = 0; i < s.length; i++){   
	        var c = s.charAt(i);
	        if (bag.indexOf(c) == -1) returnString += c;
	    }
	    return returnString;
	}
	
	function daysInFebruary (year){
		// February has 29 days in any year evenly divisible by four,
	    // EXCEPT for centurial years which are not also divisible by 400.
	    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	function DaysArray(n) {
		for (var i = 1; i <= n; i++) {
			this[i] = 31
			if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
			if (i==2) {this[i] = 29}
	   } 
	   return this
	}
	
	function isDate(dtStr){
		error = false;
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)

		var strMonth=dtStr.substring(pos1+1,pos2)
		var strDay=dtStr.substring(0,pos1)
		var strYear=dtStr.substring(pos2+1)
		strYr=strYear
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		
		for (var i = 1; i <= 3; i++) {
			if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)		
		
//		alert (month + "," + day + "," + year);		
		
		msg_str = '';
		if (pos1==-1 || pos2==-1){						
			msg_str += '- The date format should be : dd-mm-yyyy \n';
			error = true
		}
		if (strMonth.length<1 || month<1 || month>12){
			msg_str += '- Please enter a valid month \n';
			error = true
		}
		if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
			msg_str += '- Please enter a valid day \n';
			error = true
		}
		if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
			msg_str += '- Please enter a valid 4 digit year between '+minYear+' and '+maxYear+' \n';
			error = true
		}
		if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
			msg_str += '- Please enter a valid date \n';
			error = true
		}
		
		if (error) 
		{
			alert (msg_str);
			return false
		} else return true
	}
	
	function cek_tanggal(field){
		var dt=field;
		if (isDate(dt.value)==false){
			dt.focus();
			return false;
		}
	   return true;
	 }
	
